import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static int target;
    public static List<Integer> path;
    public static List<List<Integer>> ret;
    public static int sum;
    //求和
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        //不能凑成m
        int sum = (1 + n) * n / 2;
        if(sum < m) return;
        //能凑成m
        ret = new ArrayList<>();
        path = new ArrayList<>();
        target = m;
        sum = 0;

        dfs(1, n);
        for(List<Integer> list : ret){
            for(int i = 0; i < list.size(); i++){
                System.out.print(list.get(i));
                if(i != list.size() - 1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
    public static void dfs(int index, int n){
        //递归出口
        if(sum > target) return;
        if(sum == target) {
            ret.add(new ArrayList<>(path));
        }

        for(int i = index; i <= n; i++){
            if(i > target) break;
            path.add(i);
            sum += i;
            dfs(i + 1, n);
            path.remove(path.size() - 1);
            sum -= i;
        }
    }

    //电话号码
    static Map<Character, Integer> hash;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        hash = new HashMap<>();
        put(hash);

        while (in.hasNext()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            // Map<String, Integer> phone = new HashMap<>();
            List<String> phone = new ArrayList<>();
            for(int i = 0; i < n; i++){
                String s = in.next();
                s = handle(s);
                if(!phone.contains(s)) phone.add(s);
            }
            Collections.sort(phone);
            for(String s : phone){
                String ret = s.substring(0, 3) + "-" + s.substring(3, 7);
                System.out.println(ret);
            }
            System.out.println();
        }
    }
    public static String handle(String s){
        StringBuilder ret = new StringBuilder();
        char[] chs = s.toCharArray();
        for(Character ch : chs){
            if(ch == '-') continue;
            else if(Character.isDigit(ch)) ret.append(ch);
            else{
                ret.append(hash.get(ch));
            }
        }
        return ret.toString();
    }
    public static void put(Map<Character, Integer> hash){
        hash.put('A', 2);
        hash.put('B', 2);
        hash.put('C', 2);
        hash.put('D', 3);
        hash.put('E', 3);
        hash.put('F', 3);
        hash.put('G', 4);
        hash.put('H', 4);
        hash.put('I', 4);
        hash.put('J', 5);
        hash.put('K', 5);
        hash.put('L', 5);
        hash.put('M', 6);
        hash.put('N', 6);
        hash.put('O', 6);
        hash.put('P', 7);
        hash.put('Q', 7);
        hash.put('R', 7);
        hash.put('S', 7);
        hash.put('T', 8);
        hash.put('U', 8);
        hash.put('V', 8);
        hash.put('W', 9);
        hash.put('X', 9);
        hash.put('Y', 9);
        hash.put('Z', 9);
    }
}